package com.sun.lib;
/*
 *
 * #                                                   #
 * #                       _oo0oo_                     #
 * #                      o8888888o                    #
 * #                      88" . "88                    #
 * #                      (| -_- |)                    #
 * #                      0\  =  /0                    #
 * #                    ___/`---'\___                  #
 * #                  .' \\|     |# '.                 #
 * #                 / \\|||  :  |||# \                #
 * #                / _||||| -:- |||||- \              #
 * #               |   | \\\  -  #/ |   |              #
 * #               | \_|  ''\---/''  |_/ |             #
 * #               \  .-\__  '-'  ___/-. /             #
 * #             ___'. .'  /--.--\  `. .'___           #
 * #          ."" '<  `.___\_<|>_/___.' >' "".         #
 * #         | | :  `- \`.;`\ _ /`;.`/ - ` : | |       #
 * #         \  \ `_.   \_ __\ /__ _/   .-` /  /       #
 * #     =====`-.____`.___ \_____/___.-`___.-'=====    #
 * #                       `=---='                     #
 * #     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   #
 * #                                                   #
 * #               佛祖保佑         永无BUG              #
 * #                                                   #
 */

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatRadioButton;

import com.sun.lib.helper.SCheckHelper;

/**
 * Created by ESSC07 on 2021/10/14.
 */
public class SRadioButton extends AppCompatRadioButton implements SHelper<SCheckHelper> {
    private SCheckHelper mHelper;

    public SRadioButton(Context context) {
        this(context, null);
    }

    public SRadioButton(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        mHelper = new SCheckHelper(context, this, attrs);
    }

    /*public SRadioButton(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mHelper = new SCheckHelper(context, this, attrs);
    }*/

    @Override
    public SCheckHelper getHelper() {
        return mHelper;
    }

    @Override
    public void setCornerRadius(float radius) {
        mHelper.setmCornerRadius(radius);
    }

    @Override
    public void setEnabled(boolean enabled) {
        super.setEnabled(enabled);
        if (mHelper != null) mHelper.setEnabled(enabled);
    }

    @Override
    public void setSelected(boolean selected) {
        super.setSelected(selected);
        if (mHelper != null) mHelper.setSelected(true);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (mHelper != null) mHelper.drawIconWithText();
    }

    @Override
    public void setChecked(boolean checked) {
        super.setChecked(checked);
        if (mHelper != null) mHelper.setChecked(checked);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        if (mHelper != null) mHelper.onSizeChanged(w, h, oldw, oldh);
    }
}
